package Io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Practice {
    public static void main(String[] args) throws IOException {
        File file=new File("pra2.txt");
      FileInputStream fis=new FileInputStream(file);
      byte[] data=new byte[(int) file.length()];
      fis.read(data);
      String a=new String(data,StandardCharsets.UTF_8);
        System.out.println(a);
      fis.close();




       /* File file=new File("pra2.txt");
   FileOutputStream fos=new FileOutputStream(file,true);
   String data="钱钱钱钱钱";
   byte[] str=data.getBytes(StandardCharsets.UTF_8);
   fos.write(str);
   fos.write("爱爱爱爱".getBytes(StandardCharsets.UTF_8));
        System.out.println("finish");
   fos.close();


    /*    FileInputStream fis=new FileInputStream("aaaa.jpg");
        FileOutputStream fos=new FileOutputStream("aaaa_practice2.jpg");
       int len;
       byte[] data=new byte[3];
       while ((len=fis.read(data))!=-1){
           fos.write(data,0,len);
       }
       fis.close();
       fos.close();
        System.out.println("finish");






       /*FileInputStream fis=new FileInputStream("aaaa.jpg");
        FileOutputStream fos=new FileOutputStream("aaaa_practice.jpg");
        int a;
        while ((a=fis.read())!=-1){
            fos.write(a);
        }
        fis.close();
        fos.close();
        System.out.println("finish");


        /* FileInputStream fis=new FileInputStream("pra.txt");
        int a=fis.read();
        System.out.println(a);
        a=fis.read();
        System.out.println(a);
        fis.close();





       /* File file=new File("pra.txt");
        FileOutputStream fos=new FileOutputStream(file);
        fos.write(1);
        fos.write(255);
        System.out.println("finish");
        fos.close();


        */
    }
}
